<?php

class BPlugin_time extends BPlugin
{

	/**
	 * 时区
	 *
	 * @param string $timezone
	 * @return b
	 */
    function setTimezone ($timezone = 'Asia/Shanghai') 
    {
        return date_default_timezone_set($timezone);
    }

	/**
	 * 时间记录点
	 *
	 * @param string $start
	 * @param string $end
	 * @param int $dec
	 * @return f
	 */
    public function setTime($start, $end='',$dec=3) {
        static $_info = array();
        if(!empty($end)) { // 统计时间
            if(!isset($_info[$end])) {
                $_info[$end]   =  $this->Time(TRUE);
            }
            return number_format(($_info[$end]-$_info[$start]),$dec);
        } else { // 记录时间
            $_info[$start]  =  $this->Time(TRUE);
        }
    }
        
    /**
     * 获取当前时间
     * 
     * @access public
     * @static 
     * @return int
     */
    function Time($convert = true)
    {
        return microtime($convert);
    } 

}

?>
